package cn.zn.modules.appoin.entity;

import cn.zn.framework.common.abs.AbsOldMainEntity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.*;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "atr_week")
public class AtrWeekEntity extends AbsOldMainEntity {

    @TableField(value = "RULE_ID_")
    private String ruleId;

    @TableField(value = "WEEK_DAY_")
    private Integer weekDay;

    @TableField(value = "IS_WORK_")
    private Boolean isWork;

    /**
     * 工作时间集合
     */
    @TableField(exist = false)
    private List<AtrWeekWorkTimeEntity> weekWorkTimes;

    public String getWeekDayName() {
        Calendar now = Calendar.getInstance();
        Locale locale = Locale.CHINA;
        Set<Map.Entry<String, Integer>> names = now.getDisplayNames(Calendar.DAY_OF_WEEK, Calendar.LONG, locale)
                .entrySet();
        for (Map.Entry<String, Integer> name : names) {
            if (name.getValue().equals(this.weekDay)) {
                return name.getKey();
            }
        }
        return "";
    }
}